<template>
	<view>
<!--  企业税  -->
    <commonWin> </commonWin>
		<view class="top tac fw">
			<text>请完善</text>
			<text class="color">基本信息</text>
		</view>
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(1)">
				<text>营业执照注册地</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{house.area?house.area:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(2)">
				<text>企业纳税评级</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{house.taxRating?house.taxRating:'请选择'}}</text>
					<image class="image" src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>
    <view class="messageBar fz12">
      <view class="disb aic">
        <text>近一年纳税总金额</text>
        <view class="select disp aic" style="font-weight: 700">
          <u-input
              type="digit"
              maxlength="12"
              placeholder="请输入"
              inputAlign='right'
              border='none'
              v-model="house.grossTaxContribution"
          ></u-input>
          <text>元</text>
        </view>
      </view>
    </view>

		<view class="messageBar fz12">
			<view class="disb aic">
				<text>整体负债（企业+个人负债+对外担保）</text>
				<view class="select disp aic" style="font-weight: 700">
					<u-input
              type="digit"
              maxlength="12"
					    placeholder="请输入"
						  inputAlign='right'
						  border='none'
					    v-model="house.liabilities"
					></u-input>
					<text>元</text>
				</view>
			</view>
		</view>
		<u-picker :show="show" :immediateChange="true" :columns="list" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
		<view class="upBtn tac colorf" @click="toSee">提交</view>
	</view>
</template>

<script>
	import {getTax,setTax,upDateTax} from "../../api/information.js"
  import commonWin from "./commonWin.vue";
	export default {
		name:"informtionList",
    components: {commonWin},
		props:{
      flag:{
        type:Boolean,
        default:()=>{return false}
      },
      pid:{
        type:String,
        default:()=>{return ''}
      },
      ui:{
        type:String,
        default:()=>{return "0"}
      },
			isThis:{
				type:Number,
				default:()=>{return ''}
			},
      listId:{
        type:String,
        default:()=>{return ''}
      }
		},
		data() {
			return {
				show:false,
				select:null,
				status:false,
				house:{
					userId: uni.getStorageSync('userInfo').id,
					area: "",
          id:"",
					taxRating: "",
					grossTaxContribution: "",
					liabilities: "",
					isGjj: "",
					isPunchPay:'',
					isSocialSecurity:"",
					isHouse: "",
					isCar: "",
					isPolicy:''
				},
				list:[]
			};
		},
		onReady() {
			if(this.isThis==11){
        if(this.listId){
          this.getMessage()
        }
			}
		},
		methods:{
			// 获取是否填写保单资料
			getMessage(){
				getTax(this.ui).then(res => {
					if(res.data){
						this.house = res.data
						this.status = true
					}else{
						this.status = false
					}
				})
			},
			//提交
			toSee(){
				if(this.listId){
          this.house.id = this.listId
          uni.$u.toast('资料提交中...')
					upDateTax(this.house).then(res => {
						if(res.code==0){
							uni.$u.toast('保存成功')
							setTimeout(()=>{
								uni.navigateBack()
							},500)
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}else{
          uni.$u.toast('资料提交中...')
					setTax(this.house).then(res => {
						if(res.code==0){
              if (this.flag){
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=&type=1&tableId=0`
                })
              }else {
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=${this.pid}&type=0&tableId=`+res.data
                })
              }
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}
			},
			//选择
			click(i){
				this.show = true
				this.select = i
				if(i==1){
					this.list = [['渝中','江北','渝北','南岸','九龙坡','沙坪坝','大渡口','巴南','北碚','璧山','永川','江津','綦江','南川','垫江','涪陵','长寿','合川','铜梁','大足','潼南','荣昌','武隆','彭水','酉阳','秀山','黔江','石柱','忠县','梁平','万州','开州','云阳','奉节','城口','巫溪','巫山']]
				}
				if(i==2){
					this.list = [['A级','B级','C级','M级']]
				}
				if(i==3||i==4||i==5||i==6||i==7||i==8||i==9){
					this.list = [['是','否']]
				}
			},
			//确认选择
			sexSelect(e){
				this.show = false
				if(this.select==1){
					this.house.area = e.value[0]
				}
				if(this.select==2){
					this.house.taxRating = e.value[0]
				}
				if(this.select==3){
					this.house.isPunchPay = e.value[0]
				}
				if(this.select==4){
					this.house.isSocialSecurity = e.value[0]
				}
				if(this.select==5){
					this.house.isGjj = e.value[0]
				}
				if(this.select==6){
					this.house.baodan = e.value[0]
				}
				if(this.select==7){
					this.house.isHouse = e.value[0]
				}
				if(this.select==8){
					this.house.isCar = e.value[0]
				}
				if(this.select==9){
					this.house.isPolicy = e.value[0]
				}
			}
		}
	}
</script>

<style lang="scss">
.top{
	line-height: 80rpx;
	background-color: #eaf3ff;
}
.messageBar{
	min-height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	margin-bottom: 10rpx;
	background-color: #fff;
	.select{
		image{
			width: 20rpx;
			height: 30rpx;
			margin-left: 10rpx;
		}
	}
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: #0055ff;
	margin: 40rpx auto 20rpx;
}
</style>